package com.bestsoft.web.controller.flow;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.bestsoft.common.annotation.Log;
import com.bestsoft.common.core.controller.BaseController;
import com.bestsoft.common.core.domain.AjaxResult;
import com.bestsoft.common.enums.BusinessType;
import com.bestsoft.flow.domain.FlowGyslxPf;
import com.bestsoft.flow.service.IFlowGyslxPfService;
import com.bestsoft.common.utils.poi.ExcelUtil;
import com.bestsoft.common.core.page.TableDataInfo;

/**
 * 供应商流向(批发)Controller
 * 
 * @author 崔健
 * @date 2023-08-30
 */
@RestController
@RequestMapping("/flow/flow")
public class FlowGyslxPfController extends BaseController
{
    @Autowired
    private IFlowGyslxPfService flowGyslxPfService;

    /**
     * 查询供应商流向(批发)列表
     */
    @PreAuthorize("@ss.hasPermi('flow:flow:list')")
    @GetMapping("/list")
    public TableDataInfo list(FlowGyslxPf flowGyslxPf)
    {
        startPage();
        List<FlowGyslxPf> list = flowGyslxPfService.selectFlowGyslxPfList(flowGyslxPf);
        return getDataTable(list);
    }

    /**
     * 导出供应商流向(批发)列表
     */
    @PreAuthorize("@ss.hasPermi('flow:flow:export')")
    @Log(title = "供应商流向(批发)", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, FlowGyslxPf flowGyslxPf)
    {
        List<FlowGyslxPf> list = flowGyslxPfService.selectFlowGyslxPfList(flowGyslxPf);
        ExcelUtil<FlowGyslxPf> util = new ExcelUtil<FlowGyslxPf>(FlowGyslxPf.class);
        util.exportExcel(response, list, "供应商流向(批发)数据");
    }

    /**
     * 获取供应商流向(批发)详细信息
     */
    @PreAuthorize("@ss.hasPermi('flow:flow:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(flowGyslxPfService.selectFlowGyslxPfById(id));
    }

    /**
     * 新增供应商流向(批发)
     */
    @PreAuthorize("@ss.hasPermi('flow:flow:add')")
    @Log(title = "供应商流向(批发)", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FlowGyslxPf flowGyslxPf)
    {
        return toAjax(flowGyslxPfService.insertFlowGyslxPf(flowGyslxPf));
    }

    /**
     * 修改供应商流向(批发)
     */
    @PreAuthorize("@ss.hasPermi('flow:flow:edit')")
    @Log(title = "供应商流向(批发)", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FlowGyslxPf flowGyslxPf)
    {
        return toAjax(flowGyslxPfService.updateFlowGyslxPf(flowGyslxPf));
    }

    /**
     * 删除供应商流向(批发)
     */
    @PreAuthorize("@ss.hasPermi('flow:flow:remove')")
    @Log(title = "供应商流向(批发)", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(flowGyslxPfService.deleteFlowGyslxPfByIds(ids));
    }
}
